﻿#ifndef __LUA_REGISTRATION_H__
#define __LUA_REGISTRATION_H__

class Scope;

class Registration
{
public:
    Registration();
    virtual ~Registration();
    virtual void Register(lua_State* luaState, bool bGlobal) const;
private:
    friend class Scope;
    Registration* next;
};

class ScriptRegistration : public Registration
{
public:
    ScriptRegistration(const char * script, const char * chunkname);
    virtual ~ScriptRegistration();
    void Register(lua_State* luaState, bool bGlobal) const;
private:
    static void GetModuleMeta(lua_State* luaState);
private:
    const char * m_sciprt;
    const char * m_chunkname;
    static int s_ref;
};

class ModuleRegistration : public Registration
{
public:
	ModuleRegistration(const char * modulename);
	virtual ~ModuleRegistration();
	void Register(lua_State* luaState, bool bGlobal) const;
private:
	const char * m_modulename;
};

class LuaFunctionRegistration : public Registration
{
public:
    LuaFunctionRegistration(const char * name, lua_CFunction func);
    virtual ~LuaFunctionRegistration();
    void Register(lua_State* luaState, bool bGlobal) const;
private:
    const char * m_name;
    lua_CFunction m_func;
};

#endif